<template>
	<div class="app">
		<h2>我是App组件</h2>
		<h4>我的子组件Child给我的msg是：{{msg}}</h4>
		<Child ref="haizi"/>
	</div>
</template>

<script>
	import Child from './components/Child'

	export default {
		name:'App',
		components:{Child},
		data() {
			return {
				msg:'',
				a:1,
				b:2,
				c:3,
				d:4
			}
		},
		/* methods: {
			test(val){
				console.log('App中的test调用了',val)
				this.msg = val
				console.log(this)
			}
		}, */
		mounted() {
			// console.log('#',this)//App实例
			this.$refs.haizi.$on('atguigu-haha',(val)=>{
				// console.log('App中的test调用了',val)
				this.msg = val
				// console.log(this)
			})
		},
	}
</script>

<style>
	.app{
		background-color: gray;
		padding: 30px;
	}
</style>